public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i <5 ; i++) {
                System.out.println("thread");
                try {
                    Thread.sleep(1000);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
            System.out.println("thread end");
        });
        t.start();

        for (int i = 0; i < 5; i++) {
            System.out.println("main");
            try{
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
        t.join();//没有使用wait之类的单词(多线程中 wait 和 join 的效果是不一样的)
        System.out.println("main end");
    }
}
